﻿using StructureMap;
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;

using Mvc.XForms.Examples.Model;
using Mvc.XForms.Examples.Repository;

namespace Mvc.XForms.Examples {
	public class WebRegistry : Registry {
		public WebRegistry() {
			ForRequestedType<InMemoryDataContext>()
				.CacheBy(InstanceScope.Singleton)
				.TheDefault.Is.ConstructedBy(() => new InMemoryDataContext());

			ForRequestedType<IRepository<Customer>>()
				.TheDefaultIsConcreteType<InMemoryRepository<Customer>>();

			ForRequestedType<IRepository<Planet>>()
				.TheDefaultIsConcreteType<InMemoryRepository<Planet>>();

			ForRequestedType<IRepository<MailingList>>()
				.TheDefaultIsConcreteType<InMemoryRepository<MailingList>>();

			ForRequestedType<IRepository<Address>>()
				.TheDefaultIsConcreteType<InMemoryRepository<Address>>();
		}
	}
}